/*! \file arsexecitem.h
    \ingroup execmodel
    \brief This file contains declarations for common data objects for ARS execution model.
    \version 1.0

    This model is build from ARS logs. It has a tree structure.
    Normally root of this tree is ARSExecModel object.
*/

#ifndef ARSEXECITEM_H
#define ARSEXECITEM_H

#include <QHash>
#include <QList>
#include <QFile>
#include <QDateTime>
#include <QTime>

#include <arsobject.h>

class ARSExecItem;
class ARSExecWorkflowBlock;
class ARSExecWorkflowObject;
class ARSDummyObject;
class ARSDummyActiveLink;
class ARSDummyField;
class ARSDummyFilter;
class ARSDummyForm;
class ARSDummyGuide;

/*! \class ARSExecItemList
    \ingroup execmodel
    Synonim QList<ARSExecItem *>
*/
typedef QList<ARSExecItem *> ARSExecItemList;

/*! \class ARSExecItem
    \ingroup execmodel
    \brief Abstract base of all execution model classes.

    All subclasses implement function Type type() const.
*/
class ARSExecItem : public QObject
{
    Q_OBJECT
    Q_FLAGS(Type)
//    Q_PROPERTY(QString comment READ comment WRITE setComment )
    Q_PROPERTY(Type type READ type)
    Q_PROPERTY(QTime time READ time WRITE setTime)

public:
    /*! \enum Type
        ARSExecItem subclass type. Returned by int type(). \sa virtual type()
    */
    enum Type
    {
        ItemTypeModelRoot      = 0,
        /*! Model root. \sa ARSExecRootItem */
        ItemTypeRoot           = 1,
        /*! Workflow block. \sa ARSExecWorkflowBlock */
        ItemTypeWorkflowBlock  = 2,
        /*! Guide. \sa ARSExecGuide */
        ItemTypeGuide          = 4,
        /*! Workflow object (active link or filter). \sa ARSExecWorkflowObject */
        ItemTypeWorkflowObject = 8,
        /*! Action. \sa ARSExecAction */
        ItemTypeAction         = 16,
        /*! Field assignment. \sa ARSExecWorkflowFieldAssign */
        ItemTypeFieldAssign    = 32,
        /*! User text. \sa ARSExecDocumentBlock */
        ItemTypeDocumentBlock  = 64,
        /*! SQL line. \sa ARSExecSQLLine */
        ItemTypeSQLLine = 128,
        /*! API line. \sa ARSExecAPILine */
        ItemTypeAPILine = 256,
    };

    Q_DECLARE_FLAGS(Types, Type)
    /*! Constructor */
    ARSExecItem( ARSExecItem * parent = 0 );

    /*! Destructor */
    virtual ~ARSExecItem();

    /*! Returns actual type of the item. \sa Type */
    virtual Type type() const = 0;

    /*! Returns parent execution item. */
    ARSExecItem * parent() const;

    /*! Append child item \a item. */
    void appendChild( ARSExecItem * item );

    /*! Insert child item \a item before \a row. */
    void insertChild( int row, ARSExecItem * item );

    /*! Returns true if this item has at least one child item. Otherwise returns false.
        \sa childCount()
    */
    bool isEmpty() const;

    /*! Returns chidren items number.
        \sa hasChildren()
    */
    int childCount() const;

    /*! Returns child item in the \a row row. If item doesn't exist returns 0
    */
    ARSExecItem * child( int row ) const;

    /*! Returns true if item has at least one child item. Otherwise returns false
    */
    bool hasChildren() const;

    /*! Returns row of the child item \a item.
    */
    int childRow( const ARSExecItem * item ) const;

    /*! Returns row of the item.
    */
    int row() const;

    bool isLastChild() const;

    /*! Returns next sibling item in the model.
    */
    ARSExecItem * nextSibling() const;

    /*! Returns next item in the model.
    */
    ARSExecItem * nextItem() const;

    ARSExecItem * previousItem() const;

    bool isParentOf( const ARSExecItem * item ) const;
    /*! Returns the first parent item with type \a type.
        \a type can be Type or PseudoType enum value. If no items found returns 0.
    */
    ARSExecItem * findParent( Types type ) const;

    ARSExecItemList findChildren( ARSExecItem::Types type ) const;

    /*! Return item comments. Normally comments are displayed from above of the item.
    */
    QString comment() const;

    /*! Sets item comments to \a text.
    */
    void setComment( const QString & text );

    /*! Returns item execution time.
    */
    QTime time();

    /*! Sets item execution time to \a time.
    */
    void setTime( const QTime & time );

    /* virtual bool match( const ARSExecItem * item, const SearchFilterCondition & condition,
                 const ObjectsIndex & index ) const = 0; */

    static ARSExecItem * createItemByName(const QString & name, ARSExecItem * parent);

protected:
    ARSExecItemList m_childItems;
    ARSExecItem * m_parent;
    QString m_comment;
    QTime m_time;
};

Q_DECLARE_OPERATORS_FOR_FLAGS(ARSExecItem::Types)
class ARSExecModelRootItem : public ARSExecItem
{
    Q_OBJECT

public:
    ARSExecModelRootItem();
    virtual Type type() const;
};

Q_DECLARE_METATYPE(ARSExecItem *);

/*! \class ARSExecWorkflowObject
    \ingroup execmodel
    \brief Abstract base class for active links and filters.
*/
class ARSExecWorkflowObject : public ARSExecItem
{
    Q_OBJECT
    Q_ENUMS(ExecState)
    Q_ENUMS(ObjectType)
    Q_PROPERTY(ARSExecWorkflowObject::ObjectType objectType READ objectType)
    Q_PROPERTY(ExecState execState READ execState WRITE setExecState)
    Q_PROPERTY(int executionOrder READ executionOrder WRITE setExecutionOrder)

public:
    /*! \enum ExecState
        Workflow object type.
    */
    enum ObjectType
    {
        Unknown = 0,
        /*! Object is active link. */
        ActiveLink = 1,
        /*! Object is filter. */
        Filter = 2
    };

    /*! \enum ExecState
        Workflow object execution states.
    */
    enum ExecState
    {
        StateNone     = -1,/*! State is undefined. */
        StateQPassed  = 0, /*! Run-if qualification passed. 'If' actions will be processed. */
        StateQFailed  = 1, /*! Run-if qualification. 'Else' actions will be processed. */
        StateDisabled = 2, /*! Workflow object is disabled. */
        StateSkipped  = 3/*! State is undefined. */
    };

    /*! Constructor. */
    ARSExecWorkflowObject( ARSExecItem * parent = 0 );

    /*! Always ItemTypeWorkflowObject */
    Type type() const;

    /*! Indicates whether object is active link or filter. */
    virtual ObjectType objectType() const = 0;

    /*! Return execution state. \sa ExecState */
    ExecState execState() const;

    /*! Set execution state to \a state. */
    void setExecState( ExecState state );

    /*! Return execution order. */
    int executionOrder() const;

    /*! Set execution order to \a executionOrder. */
    void setExecutionOrder( int executionOrder );

private:
    ExecState m_execState;
    int m_executionOrder;
};

/*! \class ARSExecActl
    \ingroup execmodel
    \brief Provides ARS active links.
*/
class ARSExecActl : public ARSExecWorkflowObject
{
    Q_OBJECT
    Q_PROPERTY(ARSDummyActiveLink * activeLink READ activeLink WRITE setActiveLink)

public:
    /*! Constructor. */
    ARSExecActl( ARSExecItem * parent = 0 );

    /*! Always ActiveLink */
    ObjectType objectType() const;

    /*! Return active link definition. */
    ARSDummyActiveLink * activeLink() const;

    /*! Set active link definition. */
    void setActiveLink( ARSDummyActiveLink * activeLink );

private:
    ARSDummyActiveLink * m_activeLink;
};

/*! \class ARSExecFltr
    \ingroup execmodel
    \brief Provides ARS filters.
*/
class ARSExecFltr : public ARSExecWorkflowObject
{
    Q_OBJECT
    Q_PROPERTY(ARSDummyFilter * filter READ filter WRITE setFilter)

public:
    /*! Constructor. */
    ARSExecFltr( ARSExecItem * parent = 0 );

    /*! Always Filter */
    ObjectType objectType() const;

    /*! Return filter definition. */
    ARSDummyFilter * filter();

    /*! Set filter definition. */
    void setFilter( ARSDummyFilter * filter );

private:
    ARSDummyFilter * m_filter;
};

/*! \class ARSServerSideItemBase
    \ingroup execmodel
    \brief Provides server side execution items.

    ARSServerSideItemBase contains specific properties for server side items. Normally this information
    is not useful for logs analyse process. It is used to filter server logs by users or to create time
    diagrams.
*/
class ARSServerSideItemBase : public ARSExecItem
{
    Q_OBJECT

public:
    /*! Constuctor */
    ARSServerSideItemBase( ARSExecItem * parent = 0 );

    /*! Return TID. */
    QString TID() const;

    /*! Set TID. */
    void setTID( const QString & TID );

    /*! Return RPC ID. */
    QString rpcID() const;

    /*! Set RPC ID. */
    void setRpcID( const QString & rpcID );

    /*! Return queue. */
    int queue() const;

    /*! Set queue. */
    void setQueue( int queue );

    /*! Return client RPC ID. */
    QString clientRPC() const;

    /*! Set client RPC ID. */
    void setClientRPC( const QString & clientRPC );

    /*! Return user name. */
    QString user() const;

    /*! Set user name. */
    void setUser( const QString & user );

    /*! Return time and date of item execution. */
    QDateTime dateTime() const;

    /*! Set time and date of item execution. */
    void setDateTime( const QDateTime & dateTime );

private:
    QString m_TID;
    QString m_rpcID;
    int m_queue;
    QString m_clientRPC;
    QString m_user;
    QDateTime m_dateTime;
};

/*! \class ARSExecRootItem
    \ingroup execmodel
    \brief Provides root item of the model.

    It contains information about log such as creation date and time and BMC Remedy User version.
    Normally it is a root for execution model.
*/
class ARSExecRootItem: public ARSExecItem
{
    Q_OBJECT
    Q_PROPERTY(QDateTime createDateTime READ createDateTime WRITE setCreateDateTime)
    Q_PROPERTY(QString userVersion READ userVersion WRITE setUserVersion)

public:
    /*! Constructor. */
    ARSExecRootItem( ARSExecItem * parent = 0 );

    /*! Always ItemTypeRoot.*/
    Type type() const;

    /*! Return log creation date and time. */
    QDateTime createDateTime() const;

    /*! Set log creation date and time to \a dateTime. */
    void setCreateDateTime( const QDateTime & dateTime );

    /*! Return BMC Remedy User tool version used to created log. */
    QString userVersion() const;

    /*! Set BMC Remedy User tool version to \a version. */
    void setUserVersion( const QString & userVersion );

private:
    QDateTime m_createDateTime;
    QString m_userVersion;
};

/*! \class ARSExecWorkflowBlock
    \ingroup execmodel
    \brief Abstract base class for workflow execution blocks.

    Workflow block contains active links or filters that executed for one event or one phase.
    It is always linked to one form. It cannot contain other workfow blocks directly.
*/
class ARSExecWorkflowBlock: public ARSExecItem
{
    Q_OBJECT
    Q_ENUMS(Event)
    Q_PROPERTY(ARSExecWorkflowObject::ObjectType objectsType READ objectsType )
    Q_PROPERTY(ARSDummyForm * form READ form WRITE setForm)
    Q_PROPERTY(Event event READ event WRITE setEvent)

public:
    /*! \enum Event
        Type of event, emmited workflow.
    */
    enum Event
    {
        None = -1,
        EventControl        = 0,
        EventWindowOpen     = 1,
        EventSetDefault     = 2,
        EventGainFocus      = 3,
        EventLoaded         = 4,
        EventGet            = 5,
        EventMenuChoice     = 6,
        EventReturn         = 7,
        EventSubmit         = 8,
        EventCreate         = 9,
        EventSet            = 10,
        EventDelete         = 11,
        EventAfterSubmit    = 12,
        EventQuery          = 13,
        EventDisplay        = 14,
        EventWindowClose    = 15,
        EventModify         = 16,
        EventUnDisplay      = 17,
    };

    /*! Constructor. */
    ARSExecWorkflowBlock( ARSExecItem * parent = 0 );

    /*! Always ItemTypeWorkflowBlock */
    Type type() const;

    /*! Indicates whether object is active link or filter. */
    virtual ARSExecWorkflowObject::ObjectType objectsType() const = 0;

    /*! Return event, emmited workflow. */
    Event event() const;

    /*! Set event, emmited workflow. */
    void setEvent( Event event );

    /*! Return form. */
    ARSDummyForm * form() const;

    /*! Set form id. */
    void setForm( ARSDummyForm * form );

protected:
    inline int eventType( const QString & line );

private:
    Event m_event;
    ARSDummyForm * m_form;
};

/*! \class ARSExecActlBlock
    \ingroup execmodel
    \brief Provides active link execution blocks.
*/
class ARSExecActlBlock: public ARSExecWorkflowBlock
{
    Q_OBJECT
    Q_ENUMS(ScreenType)
    Q_PROPERTY(ScreenType screenType READ screenType WRITE setScreenType)
    Q_PROPERTY(ARSDummyField * linkedField READ linkedField WRITE setLinkedField)

public:
    /*! \enum ScreenType
        Values for screen type property.
    */
    enum ScreenType
    {
        ScreenQuery      = 0,
        ScreenCreate     = 1,
        ScreenDialog     = 2,
        ScreenSet        = 3,
        ScreenNone
    };

    /*! Constructor */
    ARSExecActlBlock( ARSExecItem * parent = 0 );

    /*! Always ARSExecWorkflowObject::ActiveLink */
    ARSExecWorkflowObject::ObjectType objectsType() const;

    /*! Return screen type. */
    ScreenType screenType() const;

    /*! Set screen type to \a screenType. */
    void setScreenType( ScreenType screenType );

    /*! Return linked field. */
    ARSDummyField * linkedField() const;

    /*! Set linked field to \a field. */
    void setLinkedField( ARSDummyField * field );

private:
    ScreenType m_screenType;
    ARSDummyField * m_linkedField;
};

/*! \class ARSExecFltrBlock
    \ingroup execmodel
    \brief Provides filters execution blocks.
*/
class ARSExecFltrBlock: public ARSExecWorkflowBlock
{
    Q_OBJECT
    Q_ENUMS(Phase)
    Q_PROPERTY(Phase phase READ phase WRITE setPhase)
    Q_PROPERTY(QString requestID READ requestID WRITE setRequestID)

public:
    enum Phase
    {
        None   = 0,
        Phase1 = 1,
        Phase2 = 2,
        Phase3 = 3
    };

    /*! Constructor */
    ARSExecFltrBlock( ARSExecItem * parent = 0 );

    /*! Always ARSExecWorkflowObject::Filter */
    ARSExecWorkflowObject::ObjectType objectsType() const;

    /*! Return filter phase. */
    Phase phase() const;

    /*! Set filter phase. */
    void setPhase( Phase phase );

    /*! Return request id of target record. */
    QString requestID() const;

    /*! Set request id of target record. */
    void setRequestID( const QString  & requestID );

private:
    Phase m_phase;
    QString m_requestID;
};

/*! \class ARSExecGuide
    \ingroup execmodel
    \brief Provides workflow guides.
*/
class ARSExecGuide: public ARSExecItem
{
    Q_OBJECT
    Q_PROPERTY(ARSDummyGuide * guide READ guide WRITE setGuide)
    Q_PROPERTY(ARSExecWorkflowObject::ObjectType objectsType READ objectsType WRITE setObjectsType)

public:
    /*! Constructor */
    ARSExecGuide( ARSExecItem * parent = 0 );

    /*! Always ItemTypeGuide. */
    Type type() const;

    /*! Return type of objects in guide.
        It can be ARSExecItem::ItemTypeActl or ARSExecItem::ItemTypeActl.
        \sa ARSExecItem::Type
    */
    ARSExecWorkflowObject::ObjectType objectsType();

    /*! Set type of objects in guide.
        \sa ARSExecItem::Type
    */
    void setObjectsType( ARSExecWorkflowObject::ObjectType type );

    /*! Return guide. */
    ARSDummyGuide * guide();

    /*! Set guide to \a guide. */
    void setGuide( ARSDummyGuide * guide );

private:
    ARSExecWorkflowObject::ObjectType m_objectsType;
    ARSDummyGuide * m_guide;
};

/*! \class ARSExecAction
    \ingroup execmodel
    \brief Base class for ARS actions.
*/
class ARSExecAction : public ARSExecItem
{
    Q_OBJECT
    Q_FLAGS(ActionType)
    Q_PROPERTY(ActionType actionType READ actionType)
    Q_PROPERTY(ARSExecFltrBlock::Phase adjournedPhase READ adjournedPhase WRITE setAdjournedPhase)

public:

    /*! \enum ActionType
        Action types.
    */
    enum ActionType
    {
        ActionTypeNone = 0,
        CallGuide      = 0x1,
        ChangeFields   = 0x2,
        CloseWindow    = 0x4,
        CommitChanges  = 0x8,
        DDE            = 0x10,
        DirectSQL      = 0x20,
        DSOAction      = 0x40,
        ExitGuide      = 0x80,
        GoToGuideLabel = 0x100,
        Goto           = 0x200,
        LogToFile      = 0x400,
        Message        = 0x800,
        Notify         = 0x1000,
        OLEAutomation  = 0x2000,
        OpenWindow     = 0x4000,
        RunMacro       = 0x8000,
        RunProcess     = 0x10000,
        Wait           = 0x20000,
        PushFields     = 0x40000,
        SetFields      = 0x80000,
        Service        = 0x100000
    };

    /*! Constructor. */
    ARSExecAction( ARSExecItem * parent = 0 );

    /*! Always ItemTypeAction. */
    Type type() const;

    /*! Return action type. */
    virtual ActionType actionType() const = 0;

    ARSExecFltrBlock::Phase adjournedPhase();
    void setAdjournedPhase( ARSExecFltrBlock::Phase phase );

private:
    ARSExecFltrBlock::Phase m_adjournedPhase;
};

/*! \class ARSExecAction
    \ingroup execmodel
    \brief Base class for ARS actions.
*/
class ARSExecActionCallGuide : public ARSExecAction
{
    Q_OBJECT
    Q_PROPERTY(ARSDummyGuide * guide READ guide WRITE setGuide)

public:
    ARSExecActionCallGuide( ARSExecItem * parent = 0 );

    /*! Always . */
    ActionType actionType() const;

    /*! Return guide. */
    ARSDummyGuide * guide() const;

    /*! Set guide. */
    void setGuide( ARSDummyGuide * guide );

private:
    ARSDummyGuide * m_guide;
};

/*! \class ARSExecActionChangeFields
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionChangeFields : public ARSExecAction
{
    Q_OBJECT
    Q_ENUMS(Access);
    Q_ENUMS(Visibility);
    Q_ENUMS(Font);
    Q_ENUMS(Focus);
    Q_PROPERTY(ARSDummyField * field READ field WRITE setField);
    Q_PROPERTY(Access access READ access WRITE setAccess);
    Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility);
    Q_PROPERTY(Font font READ font WRITE setFont);
    Q_PROPERTY(Focus focus READ focus WRITE setFocus);
    Q_PROPERTY(int labelColor READ labelColor WRITE setLabelColor);
    Q_PROPERTY(QString label READ label WRITE setLabel);

public:
    enum Access
    {
        AccessUnchanged   = 0,
        AccessReadOnly    = 1,
        AccessReadWrite   = 2,
        AccessDisabled    = 3
    };

    enum Visibility
    {
        VisibilityUnchanged   = 0,
        VisibilityVisible     = 1,
        VisibilityHidden      = 2
    };

    enum Font
    {
        FontUnchanged     = 0,
        FontEditor        = 1,
        FontOptional      = 2,
        FontPushButton    = 3,
        FontSystem        = 4,
        FontRadioButton   = 5,
        FontRequired      = 6,
        FontHeader1       = 7,
        FontHeader2       = 8,
        FontHeader3       = 9,
        FontNote          = 10,
        FontDetail        = 11
    };

    enum Focus
    {
        FocusUnchanged = 0,
        FocusSetFocu = 1
    };

    /*! Constructor. */
    ARSExecActionChangeFields(ARSExecItem * parent = 0);

    /*! Always ChangeFields. */
    ActionType actionType() const;

    /*! Return target field. */
    ARSDummyField * field();

    /*! Set target field. */
    void setField( ARSDummyField * field );

    /*! Return field access option. */
    Access access() const;

    /*! Set field access option. */
    void setAccess( Access access );

    /*! Return field visibility option. */
    Visibility visibility() const;

    /*! Set field visibility option. */
    void setVisibility( Visibility visibility );

    /*! Return field font. */
    Font font() const;

    /*! Set field font. */
    void setFont( Font font );

    /*! Return field focus option. */
    Focus focus() const;

    /*! Set field focus option. */
    void setFocus( Focus focus );

    /*! Return field label color. */
    int labelColor() const;

    /*! Set field label color. */
    void setLabelColor( int labelColor );

    /*! Return field label. */
    QString label() const;

    /*! Set field label. */
    void setLabel( QString label );

private:
    ARSDummyField * m_field;
    Access m_access;
    Visibility m_visibility;
    Font m_font;
    Focus m_focus;
    int m_labelColor;
    QString m_label;
};

/*! \class ARSExecActionCloseWindow
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionCloseWindow : public ARSExecAction
{
    Q_OBJECT
public:
    /*! Constructor. */
    ARSExecActionCloseWindow(ARSExecItem * parent = 0);

    /*! Always . */
    ActionType actionType() const;

private:

};

/*! \class ARSExecActionCommitChanges
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionCommitChanges : public ARSExecAction
{
    Q_OBJECT
public:
    /*! Constructor. */
    ARSExecActionCommitChanges(ARSExecItem * parent = 0);

    /*! Always . */
    ActionType actionType() const;

private:

};

/*! \class ARSExecActionDDE
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionDDE : public ARSExecAction
{
    Q_OBJECT
    Q_ENUMS(DDEAction)
    Q_PROPERTY(QString service READ service WRITE setService)
    Q_PROPERTY(QString topic READ topic WRITE setTopic)
    Q_PROPERTY(QString item READ item WRITE setItem)
    Q_PROPERTY(DDEAction action READ action WRITE setAction)
    Q_PROPERTY(QString path READ path WRITE setPath)
    Q_PROPERTY(QString command READ command WRITE setComand)
public:
    enum DDEAction
    {
        Execute = 0,
        Poke    = 1
    };

    /*! Constructor. */
    ARSExecActionDDE(ARSExecItem * parent = 0);

    /*! Always . */
    ActionType actionType() const;

    /*! Return service name. */
    QString service();

    /*! Set service name. */
    void setService( const QString & service );

    /*! Return topic. */
    QString topic();

    /*! Set topic. */
    void setTopic( const QString & topic  );

    /*! Return item. */
    QString item();

    /*! Set item. */
    void setItem( const QString & item );

    /*! Return action. */
    DDEAction action();

    /*! Set action. */
    void setAction( DDEAction action );

    /*! Return path. */
    QString path();

    /*! Set path. */
    void setPath(  const QString & path  );

    /*! Return command. */
    QString command();

    /*! Set command. */
    void setComand(  const QString & command );
private:
    QString m_service;
    QString m_topic;
    QString m_item;
    DDEAction m_action;
    QString m_path;
    QString m_command;
};

/*! \class ARSExecActionDirectSQL
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionDirectSQL : public ARSExecAction
{
    Q_OBJECT
    Q_PROPERTY(QString command READ command WRITE setCommand)
public:
    /*! Constructor. */
    ARSExecActionDirectSQL(ARSExecItem * parent = 0);

    /*! Always DirectSQL. */
    ActionType actionType() const;

    /*! Return command. */
    QString command();

    /*! Set command. */
    void setCommand( const QString & command );
private:

    QString m_command;
};

/*! \class ARSExecActionDSOAction
    \ingroup execmodel
    \brief Provides DSO action.
*/
class ARSExecActionDSOAction : public ARSExecAction
{
    Q_OBJECT
public:
    /*! Constructor. */
    ARSExecActionDSOAction(ARSExecItem * parent = 0);

    /*! Always . */
    ActionType actionType() const;

private:

};

/*! \class ARSExecActionExitGuide
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionExitGuide : public ARSExecAction
{
    Q_OBJECT
public:
    /*! Constructor. */
    ARSExecActionExitGuide(ARSExecItem * parent = 0);

    /*! Always . */
    ActionType actionType() const;

private:

};

/*! \class ARSExecActionGoToGuideLabel
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionGoToGuideLabel : public ARSExecAction
{
    Q_OBJECT
    Q_PROPERTY(QString label READ label WRITE setLabel)
public:
    /*! Constructor. */
    ARSExecActionGoToGuideLabel(ARSExecItem * parent = 0);

    /*! Always . */
    ActionType actionType() const;

    QString label() const;
    void setLabel( const QString & label );

private:
    QString m_label;
};

/*! \class ARSExecActionGoto
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionGoto : public ARSExecAction
{
    Q_OBJECT
    Q_PROPERTY(int executionOrder READ executionOrder WRITE setExecutionOrder)
public:
    /*! Constructor. */
    ARSExecActionGoto(ARSExecItem * parent = 0);

    /*! Always . */
    ActionType actionType() const;

    int executionOrder() const;
    void setExecutionOrder( int order );

private:
    int m_executionOrder;
};

/*! \class ARSExecActionLogToFile
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionLogToFile : public ARSExecAction
{
    Q_OBJECT
public:
    /*! Constructor. */
    ARSExecActionLogToFile(ARSExecItem * parent = 0);

    /*! Always . */
    ActionType actionType() const;

private:

};

/*! \class ARSExecActionMessage
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionMessage : public ARSExecAction
{
    Q_OBJECT
    Q_PROPERTY( QString text READ text WRITE setText )
public:
    /*! Constructor. */
    ARSExecActionMessage(ARSExecItem * parent = 0);

    /*! Always . */
    ActionType actionType() const;

    QString text() const;

    void setText( const QString & text );

private:
    QString m_text;
};

/*! \class ARSExecActionNotify
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionNotify : public ARSExecAction
{
    Q_OBJECT
public:
    /*! Constructor. */
    ARSExecActionNotify(ARSExecItem * parent = 0);

    /*! Always . */
    ActionType actionType() const;

private:

};

/*! \class ARSExecActionOLEAutomation
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionOLEAutomation : public ARSExecAction
{
    Q_OBJECT
public:
    /*! Constructor. */
    ARSExecActionOLEAutomation(ARSExecItem * parent = 0);

    /*! Always . */
    ActionType actionType() const;

private:

};

/*! \class ARSExecActionOpenWindow
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionOpenWindow : public ARSExecAction
{
    Q_OBJECT
public:
    /*! Constructor. */
    ARSExecActionOpenWindow(ARSExecItem * parent = 0);

    /*! Always . */
    ActionType actionType() const;

private:

};

/*! \class ARSExecActionRunMacro
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionRunMacro : public ARSExecAction
{
    Q_OBJECT
public:
    /*! Constructor. */
    ARSExecActionRunMacro(ARSExecItem * parent = 0);

    /*! Always . */
    ActionType actionType() const;

private:

};

/*! \class ARSExecActionRunProcess
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionRunProcess : public ARSExecAction
{
    Q_OBJECT
public:
    /*! Constructor. */
    ARSExecActionRunProcess(ARSExecItem * parent = 0);

    /*! Always . */
    ActionType actionType() const;

private:

};

/*! \class ARSExecActionWait
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionWait : public ARSExecAction
{
    Q_OBJECT
public:
    /*! Constructor. */
    ARSExecActionWait(ARSExecItem * parent = 0);

    /*! Always . */
    ActionType actionType() const;

private:

};

/*! \class ARSExecActionPushFields
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionPushFields : public ARSExecAction
{
    Q_OBJECT
public:
    /*! Constructor. */
    ARSExecActionPushFields(ARSExecItem * parent = 0);

    /*! Always . */
    ActionType actionType() const;

private:

};

/*! \class ARSExecActionSetFields
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionSetFields : public ARSExecAction
{
    Q_OBJECT
public:
    /*! Constructor. */
    ARSExecActionSetFields(ARSExecItem * parent = 0);

    /*! Always . */
    ActionType actionType() const;

private:

};

/*! \class ARSExecActionService
    \ingroup execmodel
    \brief Provides ARS action.
*/
class ARSExecActionService : public ARSExecAction
{
    Q_OBJECT
public:
    /*! Constructor. */
    ARSExecActionService(ARSExecItem * parent = 0);

    /*! Always Service. */
    ActionType actionType() const;

private:

};

/*! \class ARSExecFieldAssign
    \ingroup execmodel
    \brief Provides field assignment expressions.
*/
class ARSExecFieldAssign : public ARSExecItem
{
    Q_OBJECT
    Q_PROPERTY( ARSDummyField * field READ field WRITE setField )
    Q_PROPERTY( QString value READ value WRITE setValue )

public:
    /*! Constructor */
    ARSExecFieldAssign ( ARSExecItem * parent = 0 );

    /*! Always WorkflowFieldAssign */
    Type type() const;

    /*! Return field. */
    ARSDummyField * field() const;

    /*! Set field to \a field. */
    void setField( ARSDummyField * field );

    /*! Return value. */
    QString value();

    /*! Set value to \a value. */
    void setValue( const QString & value );

private:
    ARSDummyField * m_field;
    QString m_value;
    QString m_string;
};

/*! \class ARSExecSQLLine
    \ingroup execmodel
    \brief Provides SQL line.
*/
class ARSExecSQLLine : public ARSExecItem
{
    Q_OBJECT
    Q_PROPERTY( QString text READ text WRITE setText )

public:
    /*! Constructor. */
    ARSExecSQLLine( ARSExecItem * parent = 0 );

    /*! Always ItemTypeSQLLine. */
    Type type() const;

    /*! Return text. */
    QString text() const;

    /*! Set text to \a text. */
    void setText( const QString & text );

private:
    QString m_text;
};

/*! \class ARSExecSQLLine
    \ingroup execmodel
    \brief Provides API line.
*/
class ARSExecAPILine : public ARSExecItem
{
    Q_OBJECT
    Q_PROPERTY( QString text READ text WRITE setText )

public:
    /*! Constructor. */
    ARSExecAPILine( ARSExecItem * parent = 0 );

    /*! Always ItemTypeAPILine. */
    Type type() const;

    /*! Return text. */
    QString text() const;

    /*! Set text to \a text. */
    void setText( const QString & text );

private:
    QString m_text;
};

/*! \class ARSDummyObject
    \brief Class ARSDummyObject is a base class for all ARS objects.

    Warning: This is a temporary class. Will be removed in next versions.
*/
class ARSDummyObject : public QObject
{
    Q_OBJECT

public:
    enum Status
    {
        Primary,
        Secondary,
        None
    };

    enum IsModifiedFlag
    {
        Unknown = -1,
        NotModified = 0,
        Modified = 1
    };

    /*! Constructor. */
    ARSDummyObject();

    /*! Object type. */
    virtual ARSObject::Type type() const = 0;

    /*! Object name. */
    virtual QString name( bool fullName = false ) const;

    void setName( const QString & name );

    virtual bool operator== ( const ARSDummyObject & object ) const;

    static ARSDummyObject * toARSObject( const QVariant & value );

    Status status() const;

    void setStatus( Status status );

    IsModifiedFlag isModified() const;
    void setIsModified( IsModifiedFlag flag );

protected:
    Status m_status;
    QString m_name;
    IsModifiedFlag m_isModified;
};

Q_DECLARE_METATYPE(ARSDummyObject *)

typedef QList<ARSDummyObject *> ARSDummyObjectList;

class ARSDummyForm;

/*! \class ARSDummyField
    \brief Class ARSDummyField provides ars field.

    Warning: This is a temporary class. Will be removed in next versions.
*/
class ARSDummyField : public ARSDummyObject
{
    Q_OBJECT
    Q_PROPERTY(QString name READ name WRITE setName)
    Q_PROPERTY(int id READ id WRITE setID)

public:
    /*! Constructor. */
    ARSDummyField( ARSDummyForm * parentForm );

    /*! Object type. */
    ARSObject::Type type() const;

    /*! Return field id. */
    int id() const;

    /*! Set field id to \a id. */
    void setID( int id );

    /*! Return field name. */
    QString name( bool fullName = false ) const;

    ARSDummyForm * parentForm() const;

    bool operator== ( const ARSDummyObject & object ) const;

private:
    int m_id;
    ARSDummyForm * m_parentForm;
};

Q_DECLARE_METATYPE(ARSDummyField *)

typedef QList<const ARSDummyField *> ARSDummyFieldList;

/*! \class ARSDummyForm
    \brief ARSDummyForm provides ARS form.

    Warning: This is a temporary class. Will be removed in next versions.
*/
class ARSDummyForm : public ARSDummyObject
{
    Q_OBJECT
    Q_PROPERTY(QString name READ name WRITE setName)

public:
    /*! Constructor. */
    ARSDummyForm();

    /*! Destructor. */
    ~ARSDummyForm();

    /*! Object type. */
    ARSObject::Type type() const;

    /*! Return field by \a id. */
    const ARSDummyField * field( int id ) const;

    /*! Set field by \a name. */
    const ARSDummyField * field( const QString & name );

    /*! Append field \a field to form. */
    void appendField( const ARSDummyField * field );

private:
    ARSDummyFieldList m_fieldList;
};

Q_DECLARE_METATYPE(ARSDummyForm *)

typedef QList<ARSDummyForm *> ARSDummyFormList;

/*! \class ARSDummyActiveLink
    \brief Class ARSDummyActiveLink provides ars active link.

    Warning: This is a temporary class. Will be removed in next versions.
*/
class ARSDummyActiveLink : public ARSDummyObject
{
    Q_OBJECT
    Q_PROPERTY(QString name READ name WRITE setName)

public:
    /*! Constructor. */
    ARSDummyActiveLink();

    /*! Object type. */
    ARSObject::Type type() const;
};

Q_DECLARE_METATYPE(ARSDummyActiveLink *)

typedef QList<ARSDummyActiveLink *> ARSDummyActiveLinkList;

/*! \class ARSDummyFilter
    \brief Class ARSDummyFilter provides ars filter.

    Warning: This is a temporary class. Will be removed in next versions.
*/
class ARSDummyFilter : public ARSDummyObject
{
    Q_OBJECT
    Q_PROPERTY(QString name READ name WRITE setName)

public:
    /*! Constructor. */
    ARSDummyFilter();

    /*! Object type. */
    ARSObject::Type type() const;
};

Q_DECLARE_METATYPE(ARSDummyFilter *)

typedef QList<ARSDummyFilter *> ARSDummyFilterList;

/*! \class ARSDummyGuide
    \brief Class ARSDummyGuide provides ars guide.

    Warning: This is a temporary class. Will be removed in next versions.
*/
class ARSDummyGuide : public ARSDummyObject
{
    Q_OBJECT

public:
    /*! Constructor. */
    ARSDummyGuide( ARSExecWorkflowObject::ObjectType objectsType );

    /*! Object type. */
    ARSObject::Type type() const;

    QString name( bool fullName = false ) const;

    ARSExecWorkflowObject::ObjectType objectsType() const;

    bool operator== ( const ARSDummyObject & object ) const;

private:
    ARSExecWorkflowObject::ObjectType m_objectsType;
};

Q_DECLARE_METATYPE(ARSDummyGuide *)

typedef QList<ARSDummyGuide *> ARSDummyGuideList;

#endif // ARSEXECITEM_H
